/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIMantenimientoEmpleado.java
 *
 * Created on 26/10/2011, 02:13:36 AM
 */
package GUI.Empleados;

import BE.BEEmpleado;
import BL.BLCombo;
import BL.BLContacto;
import BL.BLEmpleado;
import BL.BLModelo;
import BL.BLValidaciones;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author alejandro
 */
public class GUIMantenimientoEmpleado extends javax.swing.JDialog {
    
    Boolean busqueda;
    BEEmpleado objEmpleado;

    /** Creates new form GUIMantenimientoEmpleado */
    public GUIMantenimientoEmpleado(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        
        BLValidaciones validar = new BLValidaciones();
        this.txtDNI.addKeyListener(validar.soloNumeros);
        this.txtCodigo.addKeyListener(validar.soloNumeros);
        
        busqueda=false;
        this.inicializa();
    }

    public GUIMantenimientoEmpleado(java.awt.Frame parent, boolean modal, BEEmpleado emp) {
        super(parent, modal);
        initComponents();
        
        this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        
        BLValidaciones validar = new BLValidaciones();
        this.txtDNI.addKeyListener(validar.soloNumeros);
        this.txtCodigo.addKeyListener(validar.soloNumeros);
        
        this.inicializa();
        objEmpleado=emp;
        busqueda= true;
        if (busqueda) this.modoBusqueda();
         
    }
    
    public void inicializa()
    {
        BLEmpleado blEmpleado = new BLEmpleado();
        BLModelo modelo = new BLModelo();
        this.tblEmpleado.setModel(modelo);
        
        blEmpleado.setCargoMant(this.cmbCargo);
        
        cmbEstado.addItem(new BLCombo(2,"TODOS"));
        cmbEstado.addItem(new BLCombo(1,"ACTIVO"));
        cmbEstado.addItem(new BLCombo(0,"INACTIVO"));
        
               
        modelo.addColumn("Código");
        modelo.addColumn("Cargo");
        modelo.addColumn("Nombre");
        modelo.addColumn("Apellido Paterno");
        modelo.addColumn("Apellido Materno");
        modelo.addColumn("Estado");
        modelo.addColumn("Tipo Documento");
        modelo.addColumn("Nro. Documento");
               
        
        blEmpleado.limpiaTabla(tblEmpleado);
        
        blEmpleado.buscaEmpleado(0,0,"","","","","ACTIVO",this.tblEmpleado,0); 
    
      
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlBusqueda = new javax.swing.JPanel();
        btnFiltrar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        lblCodEmpleado = new javax.swing.JLabel();
        txtCodigo = new javax.swing.JTextField();
        txtDNI = new javax.swing.JTextField();
        lblDNI = new javax.swing.JLabel();
        lblCargo = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();
        cmbEstado = new javax.swing.JComboBox();
        cmbCargo = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        lblID = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        lblApePaterno = new javax.swing.JLabel();
        txtApePaterno = new javax.swing.JTextField();
        lblApeMaterno = new javax.swing.JLabel();
        txtApeMaterno = new javax.swing.JTextField();
        btnLimpiar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblEmpleado = new javax.swing.JTable();
        pnlBotones = new javax.swing.JPanel();
        btnEditar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnAgregar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Mantenimiento de Empleado");

        pnlBusqueda.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Empleado"));
        pnlBusqueda.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        pnlBusqueda.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);

        btnFiltrar.setText("Filtrar");
        btnFiltrar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnFiltrar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnFiltrar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnFiltrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFiltrarActionPerformed(evt);
            }
        });

        lblCodEmpleado.setText("Código:");

        txtCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtCodigoKeyTyped(evt);
            }
        });

        txtDNI.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDNIKeyTyped(evt);
            }
        });

        lblDNI.setText("DNI:");

        lblCargo.setText("Cargo:");

        lblEstado.setText("Estado:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblEstado)
                    .addComponent(lblCargo)
                    .addComponent(lblCodEmpleado))
                .addGap(28, 28, 28)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                        .addComponent(lblDNI)
                        .addGap(4, 4, 4)
                        .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(cmbEstado, 0, 269, Short.MAX_VALUE)
                    .addComponent(cmbCargo, 0, 269, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCodEmpleado)
                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDNI))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCargo)
                    .addComponent(cmbCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEstado)
                    .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        lblID.setText("Nombre:");

        lblApePaterno.setText("Apellido Paterno:");

        lblApeMaterno.setText("Apellido Materno:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblID)
                    .addComponent(lblApePaterno)
                    .addComponent(lblApeMaterno))
                .addGap(36, 36, 36)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtApePaterno, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                    .addComponent(txtNombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                    .addComponent(txtApeMaterno, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblID))
                .addGap(16, 16, 16)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblApePaterno)
                    .addComponent(txtApePaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtApeMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblApeMaterno))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        btnLimpiar.setText("Limpiar");
        btnLimpiar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnLimpiar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnLimpiar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBusquedaLayout = new javax.swing.GroupLayout(pnlBusqueda);
        pnlBusqueda.setLayout(pnlBusquedaLayout);
        pnlBusquedaLayout.setHorizontalGroup(
            pnlBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBusquedaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBusquedaLayout.createSequentialGroup()
                .addContainerGap(511, Short.MAX_VALUE)
                .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25))
        );
        pnlBusquedaLayout.setVerticalGroup(
            pnlBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBusquedaLayout.createSequentialGroup()
                .addGroup(pnlBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBusquedaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        tblEmpleado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tblEmpleado.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        jScrollPane1.setViewportView(tblEmpleado);

        btnEditar.setText("Editar");
        btnEditar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnEditar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnEditar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarActionPerformed(evt);
            }
        });

        btnEliminar.setText("Eliminar");
        btnEliminar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnEliminar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnEliminar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnAgregar.setText("Agregar");
        btnAgregar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnAgregar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnAgregar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBotonesLayout = new javax.swing.GroupLayout(pnlBotones);
        pnlBotones.setLayout(pnlBotonesLayout);
        pnlBotonesLayout.setHorizontalGroup(
            pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBotonesLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlBotonesLayout.setVerticalGroup(
            pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnEliminar, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                    .addComponent(btnEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgregar, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlBusqueda, javax.swing.GroupLayout.DEFAULT_SIZE, 752, Short.MAX_VALUE)
                    .addComponent(jScrollPane1))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(298, Short.MAX_VALUE)
                .addComponent(pnlBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnFiltrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFiltrarActionPerformed
        
        BLEmpleado blEmpleado = new BLEmpleado();
        BLValidaciones validar = new BLValidaciones();
        
        int codigo;
        int dni;
        
        if (!"".equals(this.txtCodigo.getText().toString())) 
            codigo = Integer.parseInt(this.txtCodigo.getText());
        else
            codigo =0;
        
          if (!"".equals(this.txtDNI.getText().toString())) 
            dni = Integer.parseInt(this.txtDNI.getText());
        else
            dni =0;
        
        
        BLCombo idEstado = (BLCombo)cmbEstado.getSelectedItem();
        BLCombo idCargo = (BLCombo)cmbCargo.getSelectedItem();
                
        blEmpleado.buscaEmpleado(codigo,dni,idCargo.nombre,validar.validarSqlInjection(this.txtNombre.getText()), validar.validarSqlInjection(this.txtApePaterno.getText()),
         validar.validarSqlInjection(this.txtApeMaterno.getText()),idEstado.nombre,this.tblEmpleado,1); //1 = busqueda por paramtros
    // TODO add your handling code here:
      
        
        
}//GEN-LAST:event_btnFiltrarActionPerformed

private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        BLEmpleado blEmpleado = new BLEmpleado();

        blEmpleado.limpiaTabla(this.tblEmpleado);
        this.txtApeMaterno.setText("");
        this.txtApePaterno.setText("");
        this.txtNombre.setText("");
        this.txtCodigo.setText("");
        this.txtDNI.setText("");
        this.cmbCargo.setSelectedIndex(0);
        this.cmbEstado.setSelectedIndex(0);
        
    // TODO add your handling code here:
}//GEN-LAST:event_btnLimpiarActionPerformed

private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
// TODO add your handling code here:
    //GUIModificarContacto frmModificarContacto = new GUIModificarContacto(null,true);
    //frmModificarContacto.setVisible(true);
    
     int fila,numFilas;
     int columna = 0; //Columna ID
     int IDProd;
     numFilas = this.tblEmpleado.getSelectedRowCount();
     
     if (numFilas == 1){
        
     fila = this.tblEmpleado.getSelectedRow();
     
     if (JOptionPane.showConfirmDialog(null,"Desea editar el contacto?",
                 "Confirmación",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE) == 0)
        {
            
         IDProd = Integer.parseInt(this.tblEmpleado.getModel().getValueAt(fila,columna).toString());
        
         GUIModificarEmpleado frmModificarEmpleado = new GUIModificarEmpleado(null, true,IDProd);
         frmModificarEmpleado.setResizable(false);
         frmModificarEmpleado.setVisible(true);

         BLEmpleado blEmpleado = new BLEmpleado();
         blEmpleado.limpiaTabla(tblEmpleado);
         blEmpleado.buscaEmpleado(0,0,"","","","","ACTIVO",this.tblEmpleado,0);  //PARA BUSCAR TODOS LOS PRODUCTOS
            
        }
     
     
     }
     else 
         JOptionPane.showMessageDialog(null,"Debe seleccionar un empleado para editar",
                                          "Error",JOptionPane.ERROR_MESSAGE);
     
    
}//GEN-LAST:event_btnEditarActionPerformed

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        this.dispose();
}//GEN-LAST:event_btnCancelarActionPerformed

private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
        // TODO add your handling code here:
        
        GUIAgregarEmpleado frmAgregarEmpleado = new GUIAgregarEmpleado(null,true);
        frmAgregarEmpleado.setVisible(true);
        
        BLEmpleado blEmpleado = new BLEmpleado();
        blEmpleado.limpiaTabla(tblEmpleado);
        blEmpleado.buscaEmpleado(0,0,"","","","","ACTIVO",this.tblEmpleado,0);
        
}//GEN-LAST:event_btnAgregarActionPerformed

public BEEmpleado obtenerEmpleado()
{
    return objEmpleado;
}

private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        
    if (busqueda)
    {
        BLEmpleado objGestorEmpleado = new BLEmpleado();
        objEmpleado= objGestorEmpleado.llenaVentana(Integer.parseInt(tblEmpleado.getModel().getValueAt(tblEmpleado.getSelectedRow(),0).toString()));
        this.setVisible(false);
    }
    else
    {
        int fila,numFilas,vretorno=1;
        int columna = 0; //Columna ID
        int IDPrueba;
        BLEmpleado bLEmpleado = new BLEmpleado();

        fila = tblEmpleado.getSelectedRow();
        numFilas = tblEmpleado.getSelectedRowCount();
        
        if ( numFilas != 1 )
        {
            JOptionPane.showMessageDialog(null,"Debe seleccionar un empleado para eliminar",
                                          "Error",JOptionPane.ERROR_MESSAGE);
        }  
        
        else if (tblEmpleado.getModel().getValueAt(fila,5).toString().equals("INACTIVO")){
                
            JOptionPane.showMessageDialog(null,"El empleado ya se encuentra INACTIVO",
                                          "Error",JOptionPane.ERROR_MESSAGE);
        }
        else if (JOptionPane.showConfirmDialog(null,"Desea eliminar el contacto?",
                 "Confirmación",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE) == 0)
        {
            IDPrueba = Integer.parseInt(tblEmpleado.getModel().getValueAt(fila,columna).toString());
            vretorno = bLEmpleado.eliminarEmpleado(IDPrueba, tblEmpleado);
        
        }
        
        if (vretorno == 0)
        {
            JOptionPane.showMessageDialog(null,"Se eliminó el empleado",
                                          "Información",JOptionPane.INFORMATION_MESSAGE);
            bLEmpleado.limpiaTabla(tblEmpleado);
            bLEmpleado.buscaEmpleado(0,0,"","","","","ACTIVO",this.tblEmpleado,0);
        
       
        
        }
    }
        
        // TODO add your handling code here:
}//GEN-LAST:event_btnEliminarActionPerformed

private void txtCodigoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoKeyTyped
    if (this.txtCodigo.getText().length()>7)
	evt.consume();
    // TODO add your handling code here:
}//GEN-LAST:event_txtCodigoKeyTyped

private void txtDNIKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDNIKeyTyped
    if (this.txtDNI.getText().length()>7)
	evt.consume();
    // TODO add your handling code here:
}//GEN-LAST:event_txtDNIKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoEmpleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoEmpleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoEmpleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoEmpleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                GUIMantenimientoEmpleado dialog = new GUIMantenimientoEmpleado(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnFiltrar;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JComboBox cmbCargo;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblApeMaterno;
    private javax.swing.JLabel lblApePaterno;
    private javax.swing.JLabel lblCargo;
    private javax.swing.JLabel lblCodEmpleado;
    private javax.swing.JLabel lblDNI;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblID;
    private javax.swing.JPanel pnlBotones;
    private javax.swing.JPanel pnlBusqueda;
    private javax.swing.JTable tblEmpleado;
    private javax.swing.JTextField txtApeMaterno;
    private javax.swing.JTextField txtApePaterno;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtDNI;
    private javax.swing.JTextField txtNombre;
    // End of variables declaration//GEN-END:variables

    private void modoBusqueda() {
        btnAgregar.setVisible(false);
        btnEditar.setVisible(false);
        btnEliminar.setText("Aceptar");
        
    }
}
